//
//  CHItem.swift
//  DSP
//
//  Created by tucici on 2024/5/15.
//

import UIKit
import TCCKit
class CHItem: UICollectionViewCell {
    var title : UILabel!
    var block:(()->Void)?
    override init(frame: CGRect) {
        super.init(frame: frame)
        initUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func initUI(){
        title = UILabel()
        title.numberOfLines = 0
        title.font = font(16,.bold)
        title.textAlignment = .center
        title.borderWidth = 0.5
        title.borderHexColor = "#000000"
        title.textHexColor = "#000000"
        title.minimumScaleFactor = 0.6
        title.adjustsFontSizeToFitWidth = true
    
        contentView.addSubview(title)
        title.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
    }
    
    lazy var longpress : UILongPressGestureRecognizer = {
        let long = UILongPressGestureRecognizer(target: self, action: #selector(actionForlongPress))
        contentView.addGestureRecognizer(long)
        return long
    }()
    
    @objc func actionForlongPress(_ sender:UILongPressGestureRecognizer){
        if sender.state == .began{
            block?()
            let feedbackGenerator = UIImpactFeedbackGenerator(style: .medium)
            feedbackGenerator.impactOccurred()
        }
    }
}
